|
A sentinel node is a specifically designated node used with linked lists and trees as a traversal path terminator. A sentinel node does not hold or reference any data managed by the data structure. Sentinels are used as an alternative over using null as the path terminator in order to get one or more of the following benefits: # Increased speed of operations # Reduced algorithmic complexity and code size # Increased data structure robustness (arguably) == Example == Below shows an initialization of a sentinel node in a binary tree implemented in the C programming language:〔http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_andersson.aspx〕 struct jsw_node ; struct jsw_node *nil; // pointer to the sentinel node int jsw_init ( void ) As nodes that would normally link to NULL now link to "nil" (including nil itself), it removes the need for an expensive branch operation to check for NULL. NULL itself is known as a ''sentinel value'', a different approach to the same problem. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Sentinel node」の詳細全文を読む スポンサード リンク
|